<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="ckdiv">
    旧的元素
</div>
<button id="btn">获取</button>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.10.0/jquery.js"></script>
<script>
    $('#btn').click(function () {
        $('#ckdiv').empty();
        $newDiv = $('<div>新的DIV</div>')
        $('#ckdiv').append($newDiv)
        $.get("checks/data", function (result) {
            $.each(result.A, function (index, val) {
                $inpu = $('<input type="checkbox" value=""></input>')
                $inpu.val(val.code)
                if (val.status) {
                    $inpu.attr('checked', true)
                }
                $('#ckdiv').append($inpu)
                $('#ckdiv').append(('<span >' + val.name + '</span>'))
            })
            $('#ckdiv').append(('<br/>'))
            $b = $('<div></div>')
            $.each(result.B, function (index, val) {
                $inpu = $('<input style="width: 20%" type="checkbox" value=""></input>')
                $inpu.val(val.code)
                if (val.status) {
                    $inpu.attr('checked', true)
                }
                $b.append($inpu)
                $b.append(('<span>' + val.name + '</span>'))
            })
            $('#ckdiv').append($b)
        });
    });
</script>
</html>
